  
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.text.BadLocationException;
import javax.swing.*;

import info.clearthought.layout.*;
/*
 * Created by JFormDesigner on Tue Jul 31 16:17:51 EDT 2012
 */


/**
 * @author james ju
 */
public class Capture_GUI extends JPanel {
	
	private static final long serialVersionUID = 1L;
	private utils util = new utils();
	private Options option = new Options();
	private User_Connections users = new User_Connections();
	private CaptureThread ct;
	private boolean start_capture = false;
	private Packet_Builder pb;
	private boolean clicked_capture = false;
	private ArrayList<String> connection_users = new ArrayList<String>();
	private HashMap<String,ArrayList<String>> connection_users_ip = new HashMap();
	private jpcap.NetworkInterface[] neti;
	private int Interface_count = 0;
	private byte[] All_Message_toMainTextArea = "MyJPCap Packet Capture......\n".getBytes();
	private int Interface_selected;
	public Capture_GUI() {		 
		neti = jpcap.JpcapCaptor.getDeviceList();		
		Interface_selected = 0;
		initComponents();
		for(jpcap.NetworkInterface i :neti)
		{
			textArea1.append("Network Interface "+ Interface_count + ": " + i.description + "\n");
			Interface_count++;
		}
		
	}

	private void menuItem3ActionPerformed(ActionEvent e) {
		// TODO add your code here	
	}

	private void startActionPerformed(ActionEvent e) {
		start_capture = true;		
		startCapt();
	}

	private void stopActionPerformed(ActionEvent e) {
		start_capture = false;
	}

	private void button2ActionPerformed(ActionEvent e) {
		// TODO add your code here
	}
	public void startCapt()
	{			
		ct = new CaptureThread()
		{
			public Object construct()
			{
				try
				{
					while(start_capture)
					{
						try
						{
							Interface_selected = Integer.parseInt(NIC_SELECT.getText());
						}catch(java.lang.NumberFormatException e){ NIC_SELECT.setText(Integer.toString(Interface_selected)); }
						
						if(ct.startcapture(neti[Interface_selected],traffic_From.getText(),(String)send_Filter.getSelectedItem())==1)
						{
							pb = ct.getRead_data();
							
							if(pb.ep.frametype==2048)
							{								
								users.save_to_hashmap(pb, connection_users,connection_users_ip,connections,connection_ip_box);
								/**//*****************************
								Packet_Builder pp=null;
								String ipToSetNextPacket = traffic_From.getText()+":"+traffic_To.getText();								
								if(pp==null)
									pp = users.getHash_packet_builder(ipToSetNextPacket);
								if(pp==null){
									ipToSetNextPacket = traffic_To.getText()+":"+traffic_From.getText();
									pp = users.getHash_packet_builder(ipToSetNextPacket);
								}
								if(pp!=null){		
									pp.initCapturedValues();
									label18.setText(pp.src_ip.getHostAddress()+":"+pp.dst_ip.getHostAddress());
								}
								//******************************/
								pasteToTextArea2();
								connection_num.setText(Integer.toString(users.number_of_connections));
								connection_ip.setText(Integer.toString(connection_users_ip.get((String)connections.getSelectedItem()).size()));								
							}
							pasteToTextArea1();						
						}						
					}
				}catch(Exception e){ System.out.println(e); }
				
				return 0;
			}
			public void finished()
			{
				ct.interrupt();
			}
		};		
		ct.start();
	}
	
	private void frame1WindowClosing(WindowEvent e) {
		int select = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit ?","Exit",JOptionPane.YES_NO_OPTION);
		if(select == JOptionPane.YES_OPTION)
				System.exit(0);
	}

	private void sendActionPerformed(ActionEvent e) {
		/**
		 * Check if the packet we are sending is the first packet ever sent so we can manage the correct SEQ and ACK number
		 */
				String protocol = (String)send_Filter.getSelectedItem();
				Packet_Builder pp = null;
				try {
					String ipToSetNextPacket = traffic_From.getText()+":"+traffic_To.getText();
					//Check if our next packet_builder exists
					if(pp==null){
						pp = users.getHash_packet_builder(ipToSetNextPacket);
						if(pp==null){
							ipToSetNextPacket = traffic_To.getText()+":"+traffic_From.getText();
							pp = users.getHash_packet_builder(ipToSetNextPacket);
						}
					}
					//If our Packet Exists set the next sequece and ack num if not it is the first packet sent
					if(pp!=null){
						pp.initCapturedValues();						
						ct.setListentoIP_data(pp);
						ct.setFirst_Sent_Packet(false);
					}
					else 						
						ct.setFirst_Sent_Packet(true);
					
					flagcheck();
					//Send a TCP Packet [self note : retrieving and sending back Seq and Ack not working properly]
					if(protocol.compareTo("TCP/IPV4")==0)
					ct.sendPacket(neti[Interface_selected],src_IP.getText(),target_IP.getText(), dst_MAC.getText(),(String)send_Filter.getSelectedItem(),
							Integer.parseInt(src_port.getText()),Integer.parseInt(dst_port.getText()),option.urg,option.ack,option.psh,option.rst,option.syn,option.fin);
					//Send a UDP Packet
					if(protocol.compareTo("UDP")==0)
						ct.sendPacket(neti[Interface_selected],src_IP.getText(),target_IP.getText(), dst_MAC.getText(),(String)send_Filter.getSelectedItem(),
								Integer.parseInt(src_port.getText()),Integer.parseInt(dst_port.getText()),"");
					//Send a ARP Packet
					if(protocol.compareTo("ARP")==0)
						ct.sendPacket(neti[Interface_selected],src_IP.getText(),target_IP.getText(), src_MAC.getText(),dst_MAC.getText(),
								option.hardtype,option.arp_op_code);
					//Send a DNS Request
					if(protocol.compareTo("DNS_REQUEST")==0){
						String request = JOptionPane.showInputDialog(null, "DNS Request", "www.google.com");
						ct.sendPacket(neti[Interface_selected],src_IP.getText(),target_IP.getText(), dst_MAC.getText(),(String)send_Filter.getSelectedItem(),
								Integer.parseInt(src_port.getText()),Integer.parseInt(dst_port.getText()),request);
					}
					//Send ICMP Packet [Ping with type 8]
					if(protocol.compareTo("ICMPV4")==0){
						icmp_jdialog.setVisible(true);
					}
				} catch (NullPointerException n){
					System.out.println("Packet data not initialized or thread not created!!");
				}catch(UnknownHostException i){
					
				}
	}

	private void NICActionPerformed(ActionEvent e) {
		Interface_count = 0;
		for(jpcap.NetworkInterface i :neti)
		{
			textArea1.append("Network Interface "+ Interface_count + ": " + i.description + "\n");
			Interface_count++;
		}		
	}

	private void selectedActionPerformed(ActionEvent e) 
	{
		int LocalAddress = 1;
		try
		{
			if(Integer.parseInt(NIC_SELECT.getText()) < Interface_count)
			{
				Interface_selected = Integer.parseInt(NIC_SELECT.getText());
				textArea1.append("Interface " +NIC_SELECT.getText() + " has been selected\n");
				src_MAC.setText(util.ConvertoMACAddress(neti[Interface_selected].mac_address));
				src_IP.setText(neti[Interface_selected].addresses[LocalAddress].address.getHostAddress());
				src_IP2.setText(neti[Interface_selected].addresses[LocalAddress].address.getHostAddress());
				traffic_From.setText(neti[Interface_selected].addresses[LocalAddress].address.getHostAddress());
			}
			else
				textArea1.append("Non-Existing NIC Value\n");
		}catch(NumberFormatException i){ NIC_SELECT.setText(Integer.toString(Interface_selected)); }		
	}
	/**
	 * Filter for the Main Text Area..
	 */
	public void pasteToTextArea1()
	{
		switch(filters.getSelectedIndex())
		{
			case 1: if(filter_field_from.getText().compareTo(pb.ep.getDestinationAddress())==0)
					appendTotextArea(textArea1,1); 
					break;
			case 2: if(filter_field_from.getText().compareTo(pb.ep.getSourceAddress())==0)
					appendTotextArea(textArea1,1); 
					break;
			case 3:if(filter_field_from.getText().compareTo(Integer.toHexString(pb.frametype))==0)
					appendTotextArea(textArea1,1); 
					break;
			case 4:if((filter_field_from.getText().compareTo(pb.ep.getDestinationAddress())==0)
					||(filter_field_from.getText().compareTo(pb.ep.getSourceAddress())==0))
					appendTotextArea(textArea1,1); 
					break;
			case 5:if((filter_field_from.getText().compareTo(pb.src_ip.getHostAddress())==0 && filter_field_to.getText().compareTo(pb.dst_ip.getHostAddress())==0)
					|| (filter_field_from.getText().compareTo(pb.dst_ip.getHostAddress())==0 && filter_field_to.getText().compareTo(pb.src_ip.getHostAddress())==0))
					appendTotextArea(textArea1,1); 
					break;
			case 6:if(filter_field_from.getText().compareTo(pb.src_ip.getHostAddress())==0 && filter_field_to.getText().compareTo(pb.dst_ip.getHostAddress())==0)
					appendTotextArea(textArea1,1); 
					break;
			case 7:if(filter_field_from.getText().compareTo(pb.dst_ip.getHostAddress())==0 && filter_field_to.getText().compareTo(pb.src_ip.getHostAddress())==0)
					appendTotextArea(textArea1,1); 
					break;
			case 8:try{
						if(Integer.parseInt(filter_field_from.getText())==pb.protocol)
						appendTotextArea(textArea1,1);						
					}catch(java.lang.NumberFormatException e){}					
					break;
			default :appendTotextArea(textArea1,1); 
		}
	}
	/**
	 * Our watch data; watch for received packets..
	 */
	public void pasteToTextArea2()
	{
		if(Listen_next_sequence.isSelected())
		{
		/**							
			String proto = (String)send_Filter.getSelectedItem();			
			if(!option.watch_all_traffic)
			{
				if(((traffic_From.getText().compareTo(pb.src_ip.getHostAddress())==0 && traffic_To.getText().compareTo(pb.dst_ip.getHostAddress())==0))
					|| ((traffic_From.getText().compareTo(pb.dst_ip.getHostAddress())==0 && traffic_To.getText().compareTo(pb.src_ip.getHostAddress())==0))
					|| pb.frametype==2054)
				{										
					if(proto.compareTo("TCP/IPV4")==0 && pb.protocol==6) 
						appendTotextArea(textArea2,2);
					if(proto.compareTo("UDP")==0 && pb.protocol==17) 
						appendTotextArea(textArea2,2);
					if(proto.compareTo("ARP")==0 && pb.frametype==2054 && (traffic_From.getText().compareTo(util.ConvertIPAddress(pb.sender_protoaddr))==0 ||
							traffic_From.getText().compareTo(util.ConvertIPAddress(pb.target_protoaddr))==0)) appendTotextArea(textArea2,2);
				}
			}else
			{
				if((traffic_From.getText().compareTo(pb.src_ip.getHostAddress())==0 && traffic_To.getText().compareTo(pb.dst_ip.getHostAddress())==0)
						|| (traffic_From.getText().compareTo(pb.dst_ip.getHostAddress())==0 && traffic_To.getText().compareTo(pb.src_ip.getHostAddress())==0)
						|| (pb.frametype==2054 && (traffic_From.getText().compareTo(util.ConvertIPAddress(pb.sender_protoaddr))==0 ||
						traffic_From.getText().compareTo(util.ConvertIPAddress(pb.target_protoaddr))==0)))										
					appendTotextArea(textArea2,2);
			}
			*/
			appendTotextArea(textArea2,2);
		}
	}
	public void appendTotextArea(JTextArea jt,int appendType)
	{			
		try
		{
			if(appendType==1)
			{	
				jt.setText(new String(convertToBytes()));					
			}
			if(appendType==2)
			{
				jt.setText(users.getUser((String)connection_ip_box.getSelectedItem(), (String)connections.getSelectedItem()));
			}
			jt.setCaretPosition(jt.getDocument().getLength());
		}catch(java.lang.OutOfMemoryError e)
		{
			try {							
				jt.getDocument().remove(0, jt.getDocument().getLength());				
				System.out.println("Memory over use");
			} catch (BadLocationException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}		
	}
	byte[] convertToBytes()
	{		
		String frame="", ethernet = "", ipv4 = "", tcporudp= "", data="", arp="";
		ethernet = ethernet.concat("*******************************************START PACKET*******************************************\n")
		.concat("*******************************************ETHERNET*************************************************\n")
		.concat("Source MAC: " + pb.ep.getSourceAddress() + "\n")
		.concat("Destination MAC: " + pb.ep.getDestinationAddress() + "\n")
		.concat("Frame Type: " + "0x" + Integer.toHexString(pb.ep.frametype) + "\n");
		if(Integer.toHexString(pb.frametype).compareTo("800")==0) //Frame 0x800 = TCP/IP : UDP Type
		{	
			ipv4 = ipv4.concat("***********************************INTERNET PROTOCOL VERSION 4 HEADER**********************************\n")
			.concat("Source IP: " + pb.src_ip.getHostAddress() + "\n")
			.concat("Source Port: " + pb.src_port + "\n")
			.concat("Destination IP: " + pb.dst_ip.getHostAddress() + "\n")
			.concat("Destination Port: " + pb.dst_port + "\n")
			.concat("Version: " + pb.version + "\n")
			.concat("TOS: " + pb.rsv_tos + "\n")
			.concat("Total Length: " + pb.length + "\n")
			.concat("Identification: " + pb.ident + "\n")
			.concat("Dont Frag: " + pb.dont_frag +"   " + "More Frag: " + pb.more_frag +"\n")
			.concat("Frag Offset: " + pb.offset + "\n")
			.concat("TTL: " + pb.hop_limit + "\n")
			.concat("Protocol: " + pb.protocol + "\n")
			.concat("IPV4 Checksum: " + pb.checksum_ipv4 + "\n");
			if(pb.protocol==6)
			{
				tcporudp = tcporudp.concat("*******************************************TCP/IP HEADER*******************************************\n")
				.concat("Seq Num: " + pb.sequence + "\n")
				.concat("Ack Num: " + pb.ack_num + "\n")
				.concat("Flags [URG: " + pb.urg +" ACK:"+pb.ack+" PSH:"+pb.psh+ " RST:"+pb.psh+" SYN:" +pb.syn + " FIN:" +pb.fin+"]\n")
				.concat("Window Size: " + pb.window + "\n")
				.concat("TCP/IP Checksum: " + pb.checksum_tcp + "\n");
			}else
			{
				tcporudp = tcporudp.concat("*******************************************UDP HEADER*******************************************\n")
				.concat("UDP Length: " + pb.udp_Length + "\n")
				.concat("UDP Checksum: " + pb.checksum_udp + "\n");
			}
			data = data.concat("Header Hexadec : " + util.toReadbleHex(pb.pkt.header) + "\n")
			.concat("Data Hexadec : " + util.toReadbleHex(pb.pkt.data) + "\n")
			.concat("Header size : " + pb.pkt.header.length + "\n")
			.concat("Data size : " + pb.pkt.data.length + "\n");			
		}
		if(Integer.toHexString(pb.ep.frametype).compareTo("806")==0)//Frame 0x806 = ARP Type
		{
			arp = arp.concat("*******************************************ARP*******************************************\n")
					.concat("Hardware Type : " + pb.hardtype + "\n")
					.concat("Protocol Type : " + pb.protocol + "\n")
					.concat("Hardware Size : " + pb.hlen + "\n")
					.concat("Protocol Size : " + pb.plen + "\n")
					.concat("Opcode : " + pb.operation + "\n")
					.concat("Senders MAC Address : " + util.ConvertoMACAddress(pb.sender_hardaddr) + "\n")
					.concat("Senders IP Address : " + util.ConvertIPAddress((pb.sender_protoaddr)) + "\n")
					.concat("Target MAC Address : " + util.ConvertoMACAddress(pb.target_hardaddr) + "\n")
					.concat("Target IP Address : " + util.ConvertIPAddress(pb.target_protoaddr) + "\n")
					.concat("Header Hexadec : " + util.toReadbleHex(pb.pkt.header) + "\n")
					.concat("Header size : " + pb.pkt.header.length + "\n");			
		}
		frame = frame.concat(ethernet).concat(ipv4).concat(tcporudp).concat(arp).concat(data)
		.concat("*******************************************End of Packet*******************************************\n\n");
		String temp = new String(All_Message_toMainTextArea);
		temp = temp.concat(frame);
		All_Message_toMainTextArea = temp.getBytes();
		return All_Message_toMainTextArea;
	}
	private void flagcheck()
	{
		option.urg = (urg_checkbox.isSelected())?true:false;
		option.ack = (ack_checkbox.isSelected())?true:false;
		option.psh = (psh_checkbox.isSelected())?true:false;
		option.rst = (rst_checkbox.isSelected())?true:false;
		option.syn = (syn_checkbox.isSelected())?true:false;
		option.fin = (fin_checkbox.isSelected())?true:false;
	}
	private void send_FilterActionPerformed(ActionEvent e) {
		switch(send_Filter.getSelectedIndex())
		{
			case 0 : dst_MAC.setEnabled(true); src_IP.setEnabled(true); target_IP.setEnabled(true); src_port.setEnabled(true); dst_port.setEnabled(true); break;
			case 1 : dst_MAC.setEnabled(true); src_IP.setEnabled(true); target_IP.setEnabled(true); src_port.setEnabled(true); dst_port.setEnabled(true); break;
			case 2 : dst_MAC.setEnabled(true); src_IP.setEnabled(true); target_IP.setEnabled(true); src_port.setEnabled(false); dst_port.setEnabled(false); break;
			
		}
	}

	private void options_menuActionPerformed(ActionEvent e) {
		options_dialog1.setVisible(true);
	}

	private void apply_button_1ActionPerformed(ActionEvent e) {
		switch(arp_reply_code.getSelectedIndex())
		{
			case 0 : option.arp_op_code = option.ARP_REQUEST; break;
			case 1 : option.arp_op_code = option.ARP_REPLY; break;
			case 2 : option.arp_op_code = option.RARP_REQUEST; break;
			case 3 : option.arp_op_code = option.RARP_REPLY; break;
			case 4 : option.arp_op_code = option.INV_REQUEST; break;
			case 5 : option.arp_op_code = option.INV_REPLY; break;
			default : break;
		}
		switch(arp_hardware_type.getSelectedIndex())
		{
			case 0 : option.hardtype = option.HARDTYPE_ETHER; break;
			case 1 : option.hardtype = option.HARDTYPE_IEEE802; break;
			case 2 : option.hardtype = option.HARDTYPE_FRAMERELAY; break;
			default : break;
		}
		options_dialog1.setVisible(false);
	}

	private void cancelButton1ActionPerformed(ActionEvent e) {		
		options_dialog1.setVisible(false);		
	}
	/**
	 * Will search the combo box for a specific ip and will display it on textarea2
	 * set the next sequence listener so we can track the next sequence and acknowledge in the the packet
	 * true if already made a conversion
	 * false if it is the first time making conversation
	 * @param e
	 */
	private void Listen_next_sequenceActionPerformed(ActionEvent e) {
		try
		{
			if(Listen_next_sequence.isSelected())
			{
				String exist = traffic_From.getText()+":"+ traffic_To.getText();
				connection_ip_box.setSelectedItem(exist);
				if(exist.compareTo((String)connection_ip_box.getSelectedItem())!=0)
				{
					exist = traffic_To.getText()+":"+ traffic_From.getText();
					connection_ip_box.setSelectedItem(exist);
					if(exist.compareTo((String)connection_ip_box.getSelectedItem())!=0)
						System.out.println("IP does not exist");
				}
							
					ct.setListen_next_sequence(true);
			}
			else
					ct.setListen_next_sequence(false);
		}catch(Exception i){
			textArea2.append("Please start the thread\n");
		}
			
	}

	private void connectionsActionPerformed(ActionEvent e) {
		ArrayList<String> arr = connection_users_ip.get((String)connections.getSelectedItem());
		Iterator iter = arr.iterator();
		connection_ip_box.removeAllItems();
		while(iter.hasNext())
		{
			connection_ip_box.addItem((String)iter.next());
		}
		connection_ip.setText(Integer.toString(connection_users_ip.get((String)connections.getSelectedItem()).size()));
		pasteToTextArea2();
	}

	private void exitActionPerformed(ActionEvent e) {
		System.exit(0);
	}

	private void connectActionPerformed(ActionEvent e) {
		connect_jdiag.setVisible(true);
	}

	

	private void connect_closeActionPerformed(ActionEvent e) {
		connect_jdiag.setVisible(false);		
	}

	private void connect_nowActionPerformed(ActionEvent e) {
		Connect con = new Connect();
		con.initConnnection(src_IP2.getText(), Integer.parseInt(src_port2.getText()), target_IP2.getText(), Integer.parseInt(dst_port2.getText()),connect_TextArea);
		
	}

	private void icmp_sendActionPerformed(ActionEvent e) {	
		try{
			icmp_jdialog.setVisible(false);	
			ct.sendPacket(neti[Interface_selected],src_IP.getText(),target_IP.getText(),src_MAC.getText(), dst_MAC.getText(),(byte)Integer.parseInt(icmp_type.getText()),(byte)Integer.parseInt(icmp_code.getText()));
		}catch (NullPointerException n){
			System.out.println("Packet data not initialized or thread not created!!");
		}	
			
	}

	private void connect_close2ActionPerformed(ActionEvent e) {
		icmp_jdialog.setVisible(false);
	}
	
	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
		// Generated using JFormDesigner non-commercial license
		frame1 = new Frame();
		panel3 = new JPanel();
		toolBar1 = new JToolBar();
		menuBar2 = new JMenuBar();
		menu1 = new JMenu();
		connect = new JMenuItem();
		menuItem3 = new JMenuItem();
		menuItem1 = new JMenuItem();
		options_menu = new JMenuItem();
		exit = new JMenuItem();
		panel4 = new JPanel();
		label18 = new JLabel();
		label25 = new JLabel();
		connection_num = new JLabel();
		connections = new JComboBox(connection_users.toArray());
		label1 = new JLabel();
		filters = new JComboBox<>();
		filter_field_from = new JTextField();
		filter_field_to = new JTextField();
		label26 = new JLabel();
		connection_ip = new JLabel();
		connection_ip_box = new JComboBox();
		panel1 = new JPanel();
		start = new JButton();
		send = new JButton();
		Listen_next_sequence = new JToggleButton();
		label7 = new JLabel();
		send_Filter = new JComboBox<>();
		stop = new JButton();
		label13 = new JLabel();
		traffic_From = new JTextField();
		label15 = new JLabel();
		traffic_To = new JTextField();
		NIC_SELECT = new JTextField();
		label14 = new JLabel();
		src_MAC = new JTextField();
		label4 = new JLabel();
		dst_MAC = new JTextField();
		selected = new JButton();
		label5 = new JLabel();
		src_IP = new JTextField();
		label6 = new JLabel();
		target_IP = new JTextField();
		NIC = new JButton();
		label3 = new JLabel();
		src_port = new JTextField();
		label2 = new JLabel();
		dst_port = new JTextField();
		panel2 = new JPanel();
		scrollPane1 = new JScrollPane();
		textArea1 = new JTextArea();
		scrollPane2 = new JScrollPane();
		textArea2 = new JTextArea();
		options_dialog1 = new JDialog();
		label8 = new JLabel();
		label24 = new JLabel();
		urg_checkbox = new JCheckBox();
		label19 = new JLabel();
		ack_checkbox = new JCheckBox();
		label20 = new JLabel();
		psh_checkbox = new JCheckBox();
		label21 = new JLabel();
		rst_checkbox = new JCheckBox();
		label22 = new JLabel();
		syn_checkbox = new JCheckBox();
		label23 = new JLabel();
		fin_checkbox = new JCheckBox();
		label9 = new JLabel();
		label10 = new JLabel();
		arp_reply_code = new JComboBox<>();
		label12 = new JLabel();
		arp_hardware_type = new JComboBox<>();
		label11 = new JLabel();
		apply_button_1 = new JButton();
		cancel_button_1 = new JButton();
		connect_jdiag = new JDialog();
		scrollPane3 = new JScrollPane();
		connect_TextArea = new JTextArea();
		label27 = new JLabel();
		src_IP2 = new JTextField();
		label29 = new JLabel();
		src_port2 = new JTextField();
		label28 = new JLabel();
		target_IP2 = new JTextField();
		label30 = new JLabel();
		dst_port2 = new JTextField();
		connect_now = new JButton();
		connect_close = new JButton();
		icmp_jdialog = new JDialog();
		label31 = new JLabel();
		label43 = new JLabel();
		label32 = new JLabel();
		label44 = new JLabel();
		label33 = new JLabel();
		label45 = new JLabel();
		label34 = new JLabel();
		label46 = new JLabel();
		label35 = new JLabel();
		label47 = new JLabel();
		label36 = new JLabel();
		label48 = new JLabel();
		label37 = new JLabel();
		label49 = new JLabel();
		label38 = new JLabel();
		label51 = new JLabel();
		label39 = new JLabel();
		label50 = new JLabel();
		label40 = new JLabel();
		label52 = new JLabel();
		label41 = new JLabel();
		label53 = new JLabel();
		label42 = new JLabel();
		label54 = new JLabel();
		label55 = new JLabel();
		label56 = new JLabel();
		label57 = new JLabel();
		icmp_type = new JTextField();
		label58 = new JLabel();
		icmp_code = new JTextField();
		icmp_send = new JButton();
		connect_close2 = new JButton();

		//======== frame1 ========
		{
			frame1.setVisible(true);
			frame1.addWindowListener(new WindowAdapter() {
				@Override
				public void windowClosing(WindowEvent e) {
					frame1WindowClosing(e);
				}
			});
			frame1.setLayout(new BorderLayout());

			//======== this ========
			{
				this.setLayout(new BorderLayout());

				//======== panel3 ========
				{
					panel3.setLayout(new BorderLayout());

					//======== toolBar1 ========
					{
						toolBar1.setFloatable(false);

						//======== menuBar2 ========
						{

							//======== menu1 ========
							{
								menu1.setText("File");

								//---- connect ----
								connect.setText("Connect");
								connect.addActionListener(new ActionListener() {
									@Override
									public void actionPerformed(ActionEvent e) {
										connectActionPerformed(e);
									}
								});
								menu1.add(connect);

								//---- menuItem3 ----
								menuItem3.setText("Open");
								menuItem3.addActionListener(new ActionListener() {
									@Override
									public void actionPerformed(ActionEvent e) {
										menuItem3ActionPerformed(e);
									}
								});
								menu1.add(menuItem3);

								//---- menuItem1 ----
								menuItem1.setText("Save");
								menu1.add(menuItem1);

								//---- options_menu ----
								options_menu.setText("Options");
								options_menu.addActionListener(new ActionListener() {
									@Override
									public void actionPerformed(ActionEvent e) {
										options_menuActionPerformed(e);
									}
								});
								menu1.add(options_menu);

								//---- exit ----
								exit.setText("Exit");
								exit.addActionListener(new ActionListener() {
									@Override
									public void actionPerformed(ActionEvent e) {
										exitActionPerformed(e);
									}
								});
								menu1.add(exit);
							}
							menuBar2.add(menu1);
						}
						toolBar1.add(menuBar2);
					}
					panel3.add(toolBar1, BorderLayout.PAGE_START);

					//======== panel4 ========
					{
						panel4.setLayout(new GridBagLayout());
						((GridBagLayout)panel4.getLayout()).columnWidths = new int[] {22, 24, 26, 24, 23, 41, 13, 10, 11, 27, 42, 14, 9, 24, 24, 25, 19, 11, 0, 46, 26, 28, 30, 31, 36, 102, 0};
						((GridBagLayout)panel4.getLayout()).rowHeights = new int[] {0, 21, 0};
						((GridBagLayout)panel4.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0E-4};
						((GridBagLayout)panel4.getLayout()).rowWeights = new double[] {0.0, 1.0, 1.0E-4};

						//---- label18 ----
						label18.setText("Message");
						label18.setHorizontalAlignment(SwingConstants.CENTER);
						panel4.add(label18, new GridBagConstraints(2, 0, 16, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- label25 ----
						label25.setText("MAC Address:");
						label25.setHorizontalAlignment(SwingConstants.RIGHT);
						panel4.add(label25, new GridBagConstraints(18, 0, 3, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- connection_num ----
						connection_num.setText("0");
						connection_num.setHorizontalAlignment(SwingConstants.CENTER);
						panel4.add(connection_num, new GridBagConstraints(21, 0, 1, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- connections ----
						connections.addActionListener(new ActionListener() {
							@Override
							public void actionPerformed(ActionEvent e) {
								connectionsActionPerformed(e);
							}
						});
						panel4.add(connections, new GridBagConstraints(22, 0, 4, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- label1 ----
						label1.setText("Filter");
						label1.setHorizontalAlignment(SwingConstants.CENTER);
						panel4.add(label1, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- filters ----
						filters.setModel(new DefaultComboBoxModel<>(new String[] {
							"All",
							"dst_MAC",
							"src_MAC",
							"frametype",
							"dst_MAC || src_MAC",
							"Between From_IP To_IP",
							"From_IP To_IP",
							"To_IP From_IP",
							"protocol"
						}));
						panel4.add(filters, new GridBagConstraints(2, 1, 4, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- filter_field_from ----
						filter_field_from.setText("00:19:03:04:21:33");
						panel4.add(filter_field_from, new GridBagConstraints(7, 1, 5, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));
						panel4.add(filter_field_to, new GridBagConstraints(13, 1, 5, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- label26 ----
						label26.setText("IP Address:");
						label26.setHorizontalAlignment(SwingConstants.RIGHT);
						panel4.add(label26, new GridBagConstraints(19, 1, 2, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));

						//---- connection_ip ----
						connection_ip.setText("0");
						connection_ip.setHorizontalAlignment(SwingConstants.CENTER);
						panel4.add(connection_ip, new GridBagConstraints(21, 1, 1, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));
						panel4.add(connection_ip_box, new GridBagConstraints(22, 1, 4, 1, 0.0, 0.0,
							GridBagConstraints.CENTER, GridBagConstraints.BOTH,
							new Insets(0, 0, 0, 0), 0, 0));
					}
					panel3.add(panel4, BorderLayout.CENTER);
				}
				this.add(panel3, BorderLayout.NORTH);

				//======== panel1 ========
				{
					panel1.setLayout(new GridBagLayout());
					((GridBagLayout)panel1.getLayout()).columnWidths = new int[] {46, 29, 23, 26, 25, 28, 20, 22, 19, 17, 0, 36, 27, 23, 45, 26, 13, 21, 42, 15, 20, 31, 24, 29, 48, 31, 34, 0};
					((GridBagLayout)panel1.getLayout()).rowHeights = new int[] {0, 0, 15, 5, 5, 0};
					((GridBagLayout)panel1.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
					((GridBagLayout)panel1.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};

					//---- start ----
					start.setText("Start");
					start.setMaximumSize(new Dimension(73, 23));
					start.setMinimumSize(new Dimension(73, 23));
					start.setPreferredSize(new Dimension(73, 23));
					start.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							startActionPerformed(e);
						}
					});
					panel1.add(start, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- send ----
					send.setText("Packet Send");
					send.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							sendActionPerformed(e);
						}
					});
					panel1.add(send, new GridBagConstraints(10, 0, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- Listen_next_sequence ----
					Listen_next_sequence.setText("Watch");
					Listen_next_sequence.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							Listen_next_sequenceActionPerformed(e);
						}
					});
					panel1.add(Listen_next_sequence, new GridBagConstraints(13, 0, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label7 ----
					label7.setText("Type");
					panel1.add(label7, new GridBagConstraints(17, 0, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- send_Filter ----
					send_Filter.setModel(new DefaultComboBoxModel<>(new String[] {
						"TCP/IPV4",
						"UDP",
						"ARP",
						"DNS_REQUEST",
						"ICMPV4"
					}));
					send_Filter.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							send_FilterActionPerformed(e);
						}
					});
					panel1.add(send_Filter, new GridBagConstraints(20, 0, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- stop ----
					stop.setText("Stop");
					stop.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							button2ActionPerformed(e);
							stopActionPerformed(e);
						}
					});
					panel1.add(stop, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label13 ----
					label13.setText("Source Traffic");
					panel1.add(label13, new GridBagConstraints(10, 1, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- traffic_From ----
					traffic_From.setText("192.168.1.100");
					panel1.add(traffic_From, new GridBagConstraints(12, 1, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label15 ----
					label15.setText("Dest Traffic");
					panel1.add(label15, new GridBagConstraints(17, 1, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- traffic_To ----
					traffic_To.setText("192.168.1.105");
					panel1.add(traffic_To, new GridBagConstraints(20, 1, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- NIC_SELECT ----
					NIC_SELECT.setText("0");
					NIC_SELECT.setHorizontalAlignment(SwingConstants.CENTER);
					panel1.add(NIC_SELECT, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label14 ----
					label14.setText("Source Mac");
					panel1.add(label14, new GridBagConstraints(10, 2, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- src_MAC ----
					src_MAC.setText("00:19:03:04:21:33");
					panel1.add(src_MAC, new GridBagConstraints(12, 2, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label4 ----
					label4.setText("Target MAC");
					label4.setHorizontalAlignment(SwingConstants.LEFT);
					panel1.add(label4, new GridBagConstraints(17, 2, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- dst_MAC ----
					dst_MAC.setText("00:23:69:bd:09:0d");
					dst_MAC.setMinimumSize(new Dimension(98, 20));
					dst_MAC.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
					dst_MAC.setPreferredSize(new Dimension(150, 20));
					panel1.add(dst_MAC, new GridBagConstraints(20, 2, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.BOTH,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- selected ----
					selected.setText("Select");
					selected.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							selectedActionPerformed(e);
						}
					});
					panel1.add(selected, new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label5 ----
					label5.setText("Src IP");
					panel1.add(label5, new GridBagConstraints(10, 3, 1, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- src_IP ----
					src_IP.setText("192.168.1.100");
					panel1.add(src_IP, new GridBagConstraints(12, 3, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label6 ----
					label6.setText("Target IP");
					label6.setHorizontalAlignment(SwingConstants.LEFT);
					panel1.add(label6, new GridBagConstraints(17, 3, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- target_IP ----
					target_IP.setText("192.168.1.105");
					panel1.add(target_IP, new GridBagConstraints(20, 3, 4, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- NIC ----
					NIC.setText("NICLIST");
					NIC.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent e) {
							NICActionPerformed(e);
						}
					});
					panel1.add(NIC, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label3 ----
					label3.setText("Src Port");
					label3.setHorizontalAlignment(SwingConstants.CENTER);
					panel1.add(label3, new GridBagConstraints(10, 4, 1, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- src_port ----
					src_port.setText("3308");
					src_port.setMinimumSize(new Dimension(34, 22));
					panel1.add(src_port, new GridBagConstraints(12, 4, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- label2 ----
					label2.setText("Dst Port");
					label2.setHorizontalAlignment(SwingConstants.LEFT);
					panel1.add(label2, new GridBagConstraints(17, 4, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));

					//---- dst_port ----
					dst_port.setMinimumSize(new Dimension(34, 22));
					dst_port.setPreferredSize(new Dimension(34, 22));
					dst_port.setText("80");
					panel1.add(dst_port, new GridBagConstraints(20, 4, 2, 1, 0.0, 0.0,
						GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
						new Insets(0, 0, 0, 0), 0, 0));
				}
				this.add(panel1, BorderLayout.SOUTH);

				//======== panel2 ========
				{
					panel2.setLayout(new GridLayout());

					//======== scrollPane1 ========
					{

						//---- textArea1 ----
						textArea1.setEditable(false);
						scrollPane1.setViewportView(textArea1);
					}
					panel2.add(scrollPane1);

					//======== scrollPane2 ========
					{

						//---- textArea2 ----
						textArea2.setEditable(false);
						scrollPane2.setViewportView(textArea2);
					}
					panel2.add(scrollPane2);
				}
				this.add(panel2, BorderLayout.CENTER);
			}
			frame1.add(this, BorderLayout.CENTER);
			frame1.setSize(765, 545);
			frame1.setLocationRelativeTo(null);
		}

		//======== options_dialog1 ========
		{
			options_dialog1.setTitle("Options");
			Container options_dialog1ContentPane = options_dialog1.getContentPane();
			options_dialog1ContentPane.setLayout(new TableLayout(new double[][] {
				{18, 26, TableLayout.PREFERRED, 25, 22, 28, 18, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 23},
				{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 21}}));
			((TableLayout)options_dialog1ContentPane.getLayout()).setHGap(5);
			((TableLayout)options_dialog1ContentPane.getLayout()).setVGap(5);

			//---- label8 ----
			label8.setText("TCP Options");
			label8.setHorizontalAlignment(SwingConstants.CENTER);
			label8.setFont(new Font("Stencil BT", Font.PLAIN, 16));
			options_dialog1ContentPane.add(label8, new TableLayoutConstraints(1, 0, 11, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label24 ----
			label24.setText("URG");
			options_dialog1ContentPane.add(label24, new TableLayoutConstraints(1, 1, 1, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			options_dialog1ContentPane.add(urg_checkbox, new TableLayoutConstraints(2, 1, 2, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label19 ----
			label19.setText("ACK");
			options_dialog1ContentPane.add(label19, new TableLayoutConstraints(3, 1, 3, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			options_dialog1ContentPane.add(ack_checkbox, new TableLayoutConstraints(4, 1, 4, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label20 ----
			label20.setText("PSH");
			options_dialog1ContentPane.add(label20, new TableLayoutConstraints(5, 1, 5, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- psh_checkbox ----
			psh_checkbox.setText("text");
			options_dialog1ContentPane.add(psh_checkbox, new TableLayoutConstraints(6, 1, 6, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label21 ----
			label21.setText("RST");
			options_dialog1ContentPane.add(label21, new TableLayoutConstraints(7, 1, 7, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			options_dialog1ContentPane.add(rst_checkbox, new TableLayoutConstraints(8, 1, 8, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label22 ----
			label22.setText("SYN");
			options_dialog1ContentPane.add(label22, new TableLayoutConstraints(9, 1, 9, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- syn_checkbox ----
			syn_checkbox.setSelected(true);
			options_dialog1ContentPane.add(syn_checkbox, new TableLayoutConstraints(10, 1, 10, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label23 ----
			label23.setText("FIN");
			options_dialog1ContentPane.add(label23, new TableLayoutConstraints(1, 2, 1, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			options_dialog1ContentPane.add(fin_checkbox, new TableLayoutConstraints(2, 2, 2, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label9 ----
			label9.setText("ARP Options");
			label9.setHorizontalAlignment(SwingConstants.CENTER);
			label9.setFont(new Font("Stencil BT", Font.PLAIN, 16));
			options_dialog1ContentPane.add(label9, new TableLayoutConstraints(1, 6, 11, 6, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label10 ----
			label10.setText("Reply Code");
			options_dialog1ContentPane.add(label10, new TableLayoutConstraints(1, 7, 4, 7, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- arp_reply_code ----
			arp_reply_code.setModel(new DefaultComboBoxModel<>(new String[] {
				"Request",
				"Reply",
				"Rev_Request",
				"Rev_Reply",
				"Ident_Request",
				"Ident_Reply"
			}));
			options_dialog1ContentPane.add(arp_reply_code, new TableLayoutConstraints(5, 7, 9, 7, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label12 ----
			label12.setText("Hardware_typ");
			options_dialog1ContentPane.add(label12, new TableLayoutConstraints(1, 8, 4, 8, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- arp_hardware_type ----
			arp_hardware_type.setModel(new DefaultComboBoxModel<>(new String[] {
				"Ethernet",
				"IEEE802",
				"FrameRelay"
			}));
			options_dialog1ContentPane.add(arp_hardware_type, new TableLayoutConstraints(5, 8, 9, 8, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label11 ----
			label11.setText("Other Options");
			label11.setHorizontalAlignment(SwingConstants.CENTER);
			label11.setFont(new Font("Stencil BT", Font.PLAIN, 16));
			options_dialog1ContentPane.add(label11, new TableLayoutConstraints(1, 9, 11, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- apply_button_1 ----
			apply_button_1.setText("Apply");
			apply_button_1.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					apply_button_1ActionPerformed(e);
				}
			});
			options_dialog1ContentPane.add(apply_button_1, new TableLayoutConstraints(2, 14, 4, 14, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- cancel_button_1 ----
			cancel_button_1.setText("Cancel");
			cancel_button_1.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					cancelButton1ActionPerformed(e);
				}
			});
			options_dialog1ContentPane.add(cancel_button_1, new TableLayoutConstraints(7, 14, 9, 14, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			options_dialog1.pack();
			options_dialog1.setLocationRelativeTo(null);
		}

		//======== connect_jdiag ========
		{
			connect_jdiag.setTitle("Connect");
			Container connect_jdiagContentPane = connect_jdiag.getContentPane();
			connect_jdiagContentPane.setLayout(new TableLayout(new double[][] {
				{21, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 25},
				{23, 22, 24, 18, 20, 15, 21, 20, 17, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 23}}));
			((TableLayout)connect_jdiagContentPane.getLayout()).setHGap(5);
			((TableLayout)connect_jdiagContentPane.getLayout()).setVGap(5);

			//======== scrollPane3 ========
			{
				scrollPane3.setViewportView(connect_TextArea);
			}
			connect_jdiagContentPane.add(scrollPane3, new TableLayoutConstraints(1, 1, 10, 7, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label27 ----
			label27.setText("Src IP");
			connect_jdiagContentPane.add(label27, new TableLayoutConstraints(1, 9, 2, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- src_IP2 ----
			src_IP2.setText("192.168.1.100");
			connect_jdiagContentPane.add(src_IP2, new TableLayoutConstraints(3, 9, 6, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label29 ----
			label29.setText("Src Port");
			label29.setHorizontalAlignment(SwingConstants.CENTER);
			connect_jdiagContentPane.add(label29, new TableLayoutConstraints(7, 9, 8, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- src_port2 ----
			src_port2.setText("3308");
			src_port2.setMinimumSize(new Dimension(34, 22));
			connect_jdiagContentPane.add(src_port2, new TableLayoutConstraints(9, 9, 10, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label28 ----
			label28.setText("Target IP");
			label28.setHorizontalAlignment(SwingConstants.LEFT);
			connect_jdiagContentPane.add(label28, new TableLayoutConstraints(1, 10, 2, 10, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- target_IP2 ----
			target_IP2.setText("192.168.1.105");
			connect_jdiagContentPane.add(target_IP2, new TableLayoutConstraints(3, 10, 6, 10, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label30 ----
			label30.setText("Dst Port");
			label30.setHorizontalAlignment(SwingConstants.LEFT);
			connect_jdiagContentPane.add(label30, new TableLayoutConstraints(7, 10, 8, 10, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- dst_port2 ----
			dst_port2.setMinimumSize(new Dimension(34, 22));
			dst_port2.setPreferredSize(new Dimension(34, 22));
			dst_port2.setText("80");
			connect_jdiagContentPane.add(dst_port2, new TableLayoutConstraints(9, 10, 10, 10, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- connect_now ----
			connect_now.setText("Connect");
			connect_now.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					connect_nowActionPerformed(e);
				}
			});
			connect_jdiagContentPane.add(connect_now, new TableLayoutConstraints(1, 14, 4, 14, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- connect_close ----
			connect_close.setText("Close");
			connect_close.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					connect_closeActionPerformed(e);
				}
			});
			connect_jdiagContentPane.add(connect_close, new TableLayoutConstraints(7, 14, 10, 14, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			connect_jdiag.pack();
			connect_jdiag.setLocationRelativeTo(connect_jdiag.getOwner());
		}

		//======== icmp_jdialog ========
		{
			icmp_jdialog.setTitle("ICMP Options");
			Container icmp_jdialogContentPane = icmp_jdialog.getContentPane();
			icmp_jdialogContentPane.setLayout(new TableLayout(new double[][] {
				{19, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 22, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 22},
				{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 19, TableLayout.PREFERRED, 21, TableLayout.PREFERRED, 20}}));
			((TableLayout)icmp_jdialogContentPane.getLayout()).setHGap(5);
			((TableLayout)icmp_jdialogContentPane.getLayout()).setVGap(5);

			//---- label31 ----
			label31.setText("ICMP Message Type");
			icmp_jdialogContentPane.add(label31, new TableLayoutConstraints(1, 0, 5, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label43 ----
			label43.setText("ICMP Code Type = 1");
			icmp_jdialogContentPane.add(label43, new TableLayoutConstraints(7, 0, 11, 0, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label32 ----
			label32.setText("0 = Echo Reply(ping)");
			icmp_jdialogContentPane.add(label32, new TableLayoutConstraints(1, 1, 5, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label44 ----
			label44.setText("0 = Network Unreachable");
			icmp_jdialogContentPane.add(label44, new TableLayoutConstraints(7, 1, 11, 1, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label33 ----
			label33.setText("3 = Destination Unreachable");
			icmp_jdialogContentPane.add(label33, new TableLayoutConstraints(1, 2, 5, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label45 ----
			label45.setText("1 = Host Unreachable");
			icmp_jdialogContentPane.add(label45, new TableLayoutConstraints(7, 2, 11, 2, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label34 ----
			label34.setText("4 = Source Quench");
			icmp_jdialogContentPane.add(label34, new TableLayoutConstraints(1, 3, 5, 3, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label46 ----
			label46.setText("2 = Protocol Unreachable");
			icmp_jdialogContentPane.add(label46, new TableLayoutConstraints(7, 3, 11, 3, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label35 ----
			label35.setText("5 = Redirect (route change)");
			icmp_jdialogContentPane.add(label35, new TableLayoutConstraints(1, 4, 5, 4, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label47 ----
			label47.setText("3 = Port Unreachable");
			icmp_jdialogContentPane.add(label47, new TableLayoutConstraints(7, 4, 11, 4, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label36 ----
			label36.setText("8 = Echo Request(ping)");
			icmp_jdialogContentPane.add(label36, new TableLayoutConstraints(1, 5, 5, 5, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label48 ----
			label48.setText("4 = Frag needed but DF set");
			icmp_jdialogContentPane.add(label48, new TableLayoutConstraints(7, 5, 11, 5, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label37 ----
			label37.setText("11 = Time Exceeded");
			icmp_jdialogContentPane.add(label37, new TableLayoutConstraints(1, 6, 5, 6, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label49 ----
			label49.setText("5 = Source route fail");
			icmp_jdialogContentPane.add(label49, new TableLayoutConstraints(7, 6, 11, 6, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label38 ----
			label38.setText("12 = Parameter Problem");
			icmp_jdialogContentPane.add(label38, new TableLayoutConstraints(1, 7, 5, 7, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label51 ----
			label51.setText("6 = Destination network unknown");
			icmp_jdialogContentPane.add(label51, new TableLayoutConstraints(7, 7, 11, 7, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label39 ----
			label39.setText("13 = Timestamp Request");
			icmp_jdialogContentPane.add(label39, new TableLayoutConstraints(1, 8, 5, 8, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label50 ----
			label50.setText("7 = Destination host unknown");
			icmp_jdialogContentPane.add(label50, new TableLayoutConstraints(7, 8, 11, 8, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label40 ----
			label40.setText("14 = Timestamp Reply");
			icmp_jdialogContentPane.add(label40, new TableLayoutConstraints(1, 9, 5, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label52 ----
			label52.setText("8 = Source host isolated");
			icmp_jdialogContentPane.add(label52, new TableLayoutConstraints(7, 9, 11, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label41 ----
			label41.setText("17 = Address Mask Request");
			icmp_jdialogContentPane.add(label41, new TableLayoutConstraints(1, 10, 5, 10, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label53 ----
			label53.setText("9 = Network access prohibited");
			icmp_jdialogContentPane.add(label53, new TableLayoutConstraints(7, 10, 11, 10, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label42 ----
			label42.setText("18 = Address Mask Reply");
			icmp_jdialogContentPane.add(label42, new TableLayoutConstraints(1, 11, 5, 11, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label54 ----
			label54.setText("10 = Host access prohibited");
			icmp_jdialogContentPane.add(label54, new TableLayoutConstraints(7, 11, 11, 11, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label55 ----
			label55.setText("11 = Network unreachable for TOS");
			icmp_jdialogContentPane.add(label55, new TableLayoutConstraints(7, 12, 11, 12, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label56 ----
			label56.setText("12 = Host unreachable for TOS");
			icmp_jdialogContentPane.add(label56, new TableLayoutConstraints(7, 13, 11, 13, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label57 ----
			label57.setText("Type :");
			icmp_jdialogContentPane.add(label57, new TableLayoutConstraints(1, 15, 2, 15, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- icmp_type ----
			icmp_type.setText("8");
			icmp_jdialogContentPane.add(icmp_type, new TableLayoutConstraints(3, 15, 4, 15, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- label58 ----
			label58.setText("Codee :");
			icmp_jdialogContentPane.add(label58, new TableLayoutConstraints(7, 15, 8, 15, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- icmp_code ----
			icmp_code.setText("0");
			icmp_jdialogContentPane.add(icmp_code, new TableLayoutConstraints(9, 15, 10, 15, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- icmp_send ----
			icmp_send.setText("Send");
			icmp_send.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					icmp_sendActionPerformed(e);
				}
			});
			icmp_jdialogContentPane.add(icmp_send, new TableLayoutConstraints(2, 17, 4, 17, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));

			//---- connect_close2 ----
			connect_close2.setText("Close");
			connect_close2.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					connect_close2ActionPerformed(e);
				}
			});
			icmp_jdialogContentPane.add(connect_close2, new TableLayoutConstraints(6, 17, 8, 17, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
			icmp_jdialog.pack();
			icmp_jdialog.setLocationRelativeTo(icmp_jdialog.getOwner());
		}
		// JFormDesigner - End of component initialization  //GEN-END:initComponents
	}
	
	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
	// Generated using JFormDesigner non-commercial license
	private Frame frame1;
	private JPanel panel3;
	private JToolBar toolBar1;
	private JMenuBar menuBar2;
	private JMenu menu1;
	private JMenuItem connect;
	private JMenuItem menuItem3;
	private JMenuItem menuItem1;
	private JMenuItem options_menu;
	private JMenuItem exit;
	private JPanel panel4;
	private JLabel label18;
	private JLabel label25;
	private JLabel connection_num;
	private JComboBox<String> connections;
	private JLabel label1;
	private JComboBox<String> filters;
	private JTextField filter_field_from;
	private JTextField filter_field_to;
	private JLabel label26;
	private JLabel connection_ip;
	private JComboBox connection_ip_box;
	private JPanel panel1;
	private JButton start;
	private JButton send;
	private JToggleButton Listen_next_sequence;
	private JLabel label7;
	private JComboBox<String> send_Filter;
	private JButton stop;
	private JLabel label13;
	private JTextField traffic_From;
	private JLabel label15;
	private JTextField traffic_To;
	private JTextField NIC_SELECT;
	private JLabel label14;
	private JTextField src_MAC;
	private JLabel label4;
	private JTextField dst_MAC;
	private JButton selected;
	private JLabel label5;
	private JTextField src_IP;
	private JLabel label6;
	private JTextField target_IP;
	private JButton NIC;
	private JLabel label3;
	private JTextField src_port;
	private JLabel label2;
	private JTextField dst_port;
	private JPanel panel2;
	private JScrollPane scrollPane1;
	public static JTextArea textArea1;
	private JScrollPane scrollPane2;
	private JTextArea textArea2;
	private JDialog options_dialog1;
	private JLabel label8;
	private JLabel label24;
	private JCheckBox urg_checkbox;
	private JLabel label19;
	private JCheckBox ack_checkbox;
	private JLabel label20;
	private JCheckBox psh_checkbox;
	private JLabel label21;
	private JCheckBox rst_checkbox;
	private JLabel label22;
	private JCheckBox syn_checkbox;
	private JLabel label23;
	private JCheckBox fin_checkbox;
	private JLabel label9;
	private JLabel label10;
	private JComboBox<String> arp_reply_code;
	private JLabel label12;
	private JComboBox<String> arp_hardware_type;
	private JLabel label11;
	private JButton apply_button_1;
	private JButton cancel_button_1;
	private JDialog connect_jdiag;
	private JScrollPane scrollPane3;
	private JTextArea connect_TextArea;
	private JLabel label27;
	private JTextField src_IP2;
	private JLabel label29;
	private JTextField src_port2;
	private JLabel label28;
	private JTextField target_IP2;
	private JLabel label30;
	private JTextField dst_port2;
	private JButton connect_now;
	private JButton connect_close;
	private JDialog icmp_jdialog;
	private JLabel label31;
	private JLabel label43;
	private JLabel label32;
	private JLabel label44;
	private JLabel label33;
	private JLabel label45;
	private JLabel label34;
	private JLabel label46;
	private JLabel label35;
	private JLabel label47;
	private JLabel label36;
	private JLabel label48;
	private JLabel label37;
	private JLabel label49;
	private JLabel label38;
	private JLabel label51;
	private JLabel label39;
	private JLabel label50;
	private JLabel label40;
	private JLabel label52;
	private JLabel label41;
	private JLabel label53;
	private JLabel label42;
	private JLabel label54;
	private JLabel label55;
	private JLabel label56;
	private JLabel label57;
	private JTextField icmp_type;
	private JLabel label58;
	private JTextField icmp_code;
	private JButton icmp_send;
	private JButton connect_close2;
	// JFormDesigner - End of variables declaration  //GEN-END:variables

	public static void main(String args[])
	{
		new Capture_GUI().setVisible(true);		
	}
}
